package routes

import (
	"ginblog/middleware"
	"ginblog/utils"
	"github.com/gin-contrib/multitemplate"
	"github.com/gin-gonic/gin"
)

func createMyRender() multitemplate.Renderer {
	p := multitemplate.NewRenderer()
	//p.AddFromFiles("admin", "web/admin/dist/index.html")
	//p.AddFromFiles("front", "web/front/dist/index.html")
	return p
}

func InitRoute() {
	//初始化 配置
	gin.SetMode(utils.AppMode)
	//实例化路由
	r := gin.New()
	r.HTMLRender = createMyRender()
	r.Use(middleware.Logger())
	r.Use(middleware.Cors())
	r.Use(gin.Recovery())

	blog := r.Group("blog")
	{
		BlogV1(blog)
	}

	admin := r.Group("admin")
	{
		AdminV1(admin)
	}

	r.Run(utils.HttpPort)
}
